﻿@model CharacterCreation.Business.ViewModels.VMCharacter
@using System.Linq
@{
    ViewBag.Title = "Create";
}

<h2>Create Character</h2>


@using (Html.BeginForm())
{
    @Html.ValidationSummary(true)
    <fieldset>
    
        @Html.HiddenFor(m => m.Id)

        @if (!(bool)ViewBag.IsValid)
        {
            <div class="validation-block" >
                @Html.ValidationMessageFor(model => model.Name)
                @Html.ValidationMessageFor(model => model.Description)
            </div>
        }

        <dl>
            <hr />

            <dt>@Html.LabelFor(model => model.Name)</dt>
            <dd>@Html.EditorFor(model => model.Name)</dd>
            
            <hr />

            <dt>@Html.LabelFor(model => model.Description)</dt>
            <dd>@Html.EditorFor(model => model.Description)</dd>

            <hr />
            
            <dt>Race</dt>
            <dd>@Html.DropDownListFor(m => m.Race, Model.Races)</dd>
        </dl>
        
        <!-- Character Statistics -->
        <h3>Statistics</h3>
        <table>
            <tr>
                <th>
                    Name
                </th>
                <th>
                    Rolled value
                </th>
                <th>
                    Moved value
                </th>
                <th>
                    Racial bonus
                </th>
                <th>
                    Total
                </th>
                <th>
                    Information
                </th>
            </tr>

            @for (int i = 0; i < Model.Statistics.Count; ++i )
            {
                @Html.PartialFor(m => Model.Statistics[i], "CharacterStatistic_Create")
            }
        </table>
        <hr />
        
        <table>
            <tr><th>left</th><th>right</th></tr>
            @for (int i = 0; i < ViewBag.LeftStats.Count; ++i)
            {
                <tr>
                    <td>@ViewBag.LeftStats[i]</td>
                    <td>@ViewBag.RightStats[i]</td>
                </tr>
            }
            <tr><td>@ViewBag.LeftStatTotal</td>
                <td>@ViewBag.RightStatTotal</td></tr>
        </table>
        <hr />
        

        <input type="submit" value="Save" />
    </fieldset>
}

<div>
    @Html.ActionLink("Back to List", "Index")
</div>